🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / feature / messaging / src / commonMain / kotlin / org / meshtastic / feature / messaging / translation / MessageTranslationService.kt
Displaying Raw • Download
feature/messaging/src/commonMain/kotlin/org/meshtastic/feature/messaging/translation/MessageTranslationService.kt bc5cf83df7fd6b405ffc521d7c3ed4e1f3e8271a (bc5cf83d) Text, 2.76 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.messaging.translation
T8b949e/**
* Service interface for translating chat messages on-device.
*
* Google flavor provides an ML Kit implementation; fdroid/desktop/iOS provide a no-op that returns
* [TranslationResult.Unavailable], which hides the translate action entirely.
*/
Tff7b72interface T56d364MessageTranslationService Tb4b4b4{
T8b949e/**
* Translate plain chat text to the target locale, detecting the source language on-device. Never downloads language
* models — missing models are reported as [TranslationResult.ModelDownloadRequired] so the UI can ask the user
* before pulling ~30MB per language.
*/
Tff7b72suspend Tff7b72fun Td2a8fftranslateTb4b4b4(Te6edf3textTb4b4b4: Tffa657StringTb4b4b4, Te6edf3targetLocaleTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3TranslationResult
T8b949e/** Check whether translating into the given locale is possible on this platform (model downloadable). */
Tff7b72suspend Tff7b72fun Td2a8ffisLanguageAvailableTb4b4b4(Te6edf3localeTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Tffa657Boolean
T8b949e/** Download the translation models for the given language tags. Only meaningful on google flavor. */
Tff7b72suspend Tff7b72fun Td2a8ffdownloadLanguageModelsTb4b4b4(Te6edf3languageTagsTb4b4b4: Te6edf3ListTff7b72<Tffa657StringTff7b72>Tb4b4b4)Tb4b4b4: Te6edf3DownloadResult
Tb4b4b4}
T8b949e/** Result of a message translation attempt. */
Tff7b72sealed Tff7b72class T56d364TranslationResult Tb4b4b4{
T8b949e/** Translation succeeded. [translatedText] contains the message text in the target locale. */
Tff7b72data Tff7b72class T56d364SuccessTb4b4b4(Tff7b72val Te6edf3translatedTextTb4b4b4: Tffa657StringTb4b4b4) Tb4b4b4: Te6edf3TranslationResultTb4b4b4(Tb4b4b4)
T8b949e/** The message is already in the target language; there is nothing to translate or persist. */
Tff7b72data Tff7b72object T56d364NotRequired Tb4b4b4: Te6edf3TranslationResultTb4b4b4(Tb4b4b4)
T8b949e/** The models for [languageTags] must be downloaded (an estimated [estimatedSizeMb]) before translating. */
Tff7b72data Tff7b72class T56d364ModelDownloadRequiredTb4b4b4(Tff7b72val Te6edf3languageTagsTb4b4b4: Te6edf3ListTff7b72<Tffa657StringTff7b72>Tb4b4b4, Tff7b72val Te6edf3estimatedSizeMbTb4b4b4: Tffa657IntTb4b4b4) Tb4b4b4: Te6edf3TranslationResultTb4b4b4(Tb4b4b4)
T8b949e/** Translation is not available on this platform/flavor, or the source language could not be determined. */
Tff7b72data Tff7b72object T56d364Unavailable Tb4b4b4: Te6edf3TranslationResultTb4b4b4(Tb4b4b4)
Tb4b4b4}
T8b949e/** Result of a model download attempt. */
Tff7b72sealed Tff7b72class T56d364DownloadResult Tb4b4b4{
Tff7b72data Tff7b72object T56d364Success Tb4b4b4: Te6edf3DownloadResultTb4b4b4(Tb4b4b4)
Tff7b72data Tff7b72class T56d364FailedTb4b4b4(Tff7b72val Te6edf3reasonTb4b4b4: Tffa657StringTb4b4b4) Tb4b4b4: Te6edf3DownloadResultTb4b4b4(Tb4b4b4)
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.04s